<extend name="layout/home" />
<block name="title"><title>汇盟通宝</title></block>
<block name="tit">汇盟通宝</block>
<block name="content">
    <link href="__PUBLIC__/home/css/style/pay.css" type="text/css" rel="stylesheet">
    <div class="weui_tab" style="background:#FFF;">
        <div class="weui_tab_bd">
            <form action="__MODULE__/inte/settlement" method="post">
                <div class="weui_tab_bd" style="margin-top:60px; margin-bottom:80px;">
                    <if condition="$sf neq 1">
                        <div class="xzqy" flag="1">
                            <p flag='water'>选择代理区域:</p>
                            <select id="prov" name="prov" class="select-sheng">
                                <option value="">请选择</option>
                            </select>
                            <span>省</span>
                            <select  id="city" name="city" class="select-shi">
                                <option value="">请选择</option>
                            </select>
                            <span>市</span>
                            <if condition = "($sf eq 3) or ($sf eq 2)">
                                <select id="area"  flag="yy" name="area" class="select-qu">
                                    <option value="">请选择</option>
                                </select>
                                <span>区/县</span>
                            </if>
                        </div>
                    </if>
                    <if condition="$sf neq 1">
                        <div class="weui_cells weui_cells_radio">
                            <label class="weui_cell weui_check_label">
                                <div class="weui_cell_bd weui_cell_primary" style="font-size:0.8rem;">
                                    <p style="float:left;">你选择的代理区域是：</p>
                                    <p class="dlqy"><span id="sp"></span><span id="sc"></span><span id="sa"></span></p>
                                </div>
                                <div style="display: none;" class="queren">待确认</div>
                            </label>
                        </div>
                    </if>
                    <if condition="$sf eq 2">
                        <div class="inquiry" style="display: none;">
                            <div class="quiry">
                                <p class="quiry_1">查询</p>
                                <p class="quiry_2" style="display: block;">该区域还有<span>9</span>名代理资格</p>
                            </div>
                            <table class="sheet">
                                <tbody>
                                    <tr>
                                        <th class="sheet_1">序号</th>
                                        <th class="sheet_2">账号</th>
                                        <th class="sheet_3">姓名</th>
                                        <th class="sheet_4">日期</th>
                                    </tr>
                                    <tr style="display: table-row;">
                                        <td>1</td>
                                        <td>第三打得过个</td>
                                        <td>搜狗的</td>
                                        <td>2017.07.28</td>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </if>
                    <div class="subordinate">
                        <if condition="$sf eq 1">
                            <p flag="noid">所属招商中心：</p>
                            <else /><p>所属招商中心：</p>
                        </if>
                        <select class="insubo" name="mc_id">
                            <option value="">请选择</option>
                            <foreach  name="mc" item="mlist">
                                <option value="{$mlist.mid}">{$mlist.name}</option>
                            </foreach>
                        </select>
                    </div>
                    <input class="weui_btn weui_btn_warn" style="width:80%;text-align:center;" value="确认" type="submit">
                </div>
            </form>
        </div>
    </div>
    <script type="text/javascript">
    $(function(){
    //选择代理区域
        // $('#prov').click(function(){
            $.get("__MODULE__/index/address",{'pid':0},function(data){
                // 遍历数据进行添加
                for(var i=0;i<data.length;i++){
                var op = $('<option value="'+data[i].areaid+'">'+data[i].areaname+'</option>');
                $('#prov').append(op);
                }
            },'json');
        // });
        $('#prov').change(function(){
            // 获取当前省的id
            var pid = $(this).val();
            // 通过省的id去获取市的内容
            $.get("__MODULE__/index/address",{'pid':pid},function(data){
                $('#city').empty().html('<option value="">请选择</option>');
                $('#area').empty().html('<option value="">请选择</option>');
                // 遍历数据进行添加
                for(var i=0;i<data.length;i++){
                   var op = $('<option value="'+data[i].areaid+'">'+data[i].areaname+'</option>');
                    $('#city').append(op);
                }
            },'json');
            $('input[name=detail]').removeAttr('disabled');
        });
        $('#city').change(function(){
            // 获取当前省的id
            var pid = $(this).val();
            // 通过省的id去获取市的内容
            $.get("__MODULE__/index/address",{'pid':pid},function(data){
                $('#area').empty().html('<option value="">请选择</option>');
                // 遍历数据进行添加
                for(var i=0;i<data.length;i++){
                    var op = $('<option value="'+data[i].areaid+'">'+data[i].areaname+'</option>');
                    $('#area').append(op);
                }
            },'json');
        });
    //表单限制
            var prov = 0;
            var PROV = false;
            var city = 0;
            var CITY = false;
            var ZSZ = false;
            var service = $('select[name=area]').attr('flag');
            if($('.queren').text()){
                var DLQ = false;
                $('.queren').click(function(){
                    var abc = $(this).text();
                    if(abc == '待确认'){
                        $(this).text('已确认');
                        DLQ = true;
                    }else{
                        $(this).text('待确认');
                        DLQ = false;
                    }
                });
            };
            $('select[name=prov]').change(function(){
                prov = $(this).val();
                $('#sp').text($(this).find("option:selected").text());
                $('#sc').empty();
                $('#sa').empty();
                DLQ = false;
                if(prov){
                    PROV = true;
                }else{
                    PROV = false;
                }
                CITY = false;
                if(service){
                    AREA = false; 
                }
            });
            $('select[name=city]').change(function(){
                city = $(this).val();
                $('#sc').text($(this).find("option:selected").text());
                $('#sa').empty();
                $('.queren').css('display','block').text('待确认');
                DLQ = false;
                if(city){
                    CITY = true;
                }else{
                    CITY = false;
                }
                if(service){
                    AREA = false; 
                }
            });
            if(service){
                var area = 0;
                var AREA = false;
                $('select[name=area]').change(function(){
                    area = $(this).val();
                    $('.queren').css('display','block').text('待确认');
                    DLQ = false;
                    $('#sa').text($(this).find("option:selected").text());
                    if(area){
                        AREA = true;
                    }else{
                        AREA = false;
                    }
                });
            }
            $('select[name=mc_id]').change(function(){
                var mc = $(this).val();
                if(mc){
                    ZSZ = true;
                }else{
                    ZSZ = false;
                }
            });
            $('form').submit(function(){
                if(!service){
                    AREA = true;
                }
                if(!DLQ){
                    DQL = true;
                }
                if($('.subordinate p:nth-child(1)').attr('flag')){
                    PROV = true;
                    CITY = true;
                    DLQ = true;
                };
                if(PROV && CITY && AREA && DLQ && ZSZ){
                    return true;
                }else{
                    return false;
                }
            });
    });
    </script>
</block>
